{extend name='public/window' /}

{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="form">
                <input type="hidden" name="id" id="token" value="{$info.id}"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">标题 *</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入标题"
                               value="{$info.title}" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item merch">
                    <label class="layui-form-label">图片 *</label>
                    <div style="width: 500px;height: 280px;display: inline-block; text-align: center;"
                         id="image1"><img id="img1"  src="{$info.image}" style="width: 100%; height: 100%;" >
                    </div>
                </div>
                <div class="layui-form-item merch">
                    <label class="layui-form-label">内容 *</label>
                    <div class="layui-input-block">
                        <textarea id="content" lay-verify="content"  name="content">{$info.content}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-layout-admin " style="width: 100%">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0px;text-align: center;">
                            <button class="layui-btn" lay-submit="" lay-filter="add">{:__('Submit')}</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    layui.use(['element', 'form', 'table', 'jquery', 'lucky', 'laydate', 'xmSelect', 'layedit'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var lucky = layui.lucky;
        var layedit = layui.layedit;
        var id_lists = [];
        laydate.render({
            elem: '#send_time',
            type: 'datetime',
            trigger: 'click',
            min: minDate()
        });
        layedit.set({	//设置图片接口
            uploadImage: {
                url: "{:url('Common/UpEditorPic')}", //接口url
                type: 'post'
            }
        });
        //创建一个编辑器，lay_edit为textarea标签的id值
        var index = layedit.build('content', {
            width: 200,
            height: 350    //设置编辑器的高度
        });
        //赋值
        form.verify({
            content: function(value) {
                return layedit.sync(index);
            }
        });
        form.on('select(type)', function (data) {
            var type = data.value;
            if (type == 2) {
                $(".send").css('display', 'block');
            } else {
                $(".send").css('display', 'none');
            }
        });

        form.on('submit(add)', function (data) {
            var image = $("#img1").attr("src");
            data.field.image = image // 添加type
            lucky.FormSubmit("{:url('see')}",data.field,true);
            return false;
        });
    })
    function minDate() {
        var now = new Date();
        return now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate();
    }

</script>

{/block}

